package com.woniuxy.jwt;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @BelongsProject: java-85-course-code
 * @BelongsPackage: com.woniuxy.jwt
 * @Author: LiTongMiao
 * @Date: 2022/2/24 10:14
 * @Description: TODO
 */
public class ParseJwt {
    public static void main(String[] args) {
        String token="eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI4ODgiLCJzdWIiOiJhZG1pbiIsImlhdCI6MTY0NTUxNjEwMCwiZXhwIjoxNjQ1NTE2MTU5LCJ1c2VybmFtZSI6Im1heXVoYW5nIiwicGFzc3dvcmQiOjEyMzQ1Nn0.KpkMoxeZsyYrqw4K9XWVWcGqCb5Inu8WHTMavW5sbbI";
        Claims claims = Jwts.parser().setSigningKey("woniuxy").parseClaimsJws(token).getBody();
        System.out.println(claims.getId());
        System.out.println(claims.getSubject());
        System.out.println(claims.getIssuedAt());
        System.out.println(claims.get("username"));
        System.out.println(claims.get("password"));
    }
}
